package net.borlis.sample.services.facade.ws.response;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author alex@borlis.net on 02.06.2014.
 */
@XmlRootElement
public class CurrencyResponse {

    @XmlElement
    private Long id;

    @XmlElement
    private String code;

    @XmlElement
    private String name;

    public CurrencyResponse() {
    }

    public CurrencyResponse(Long id, String code, String name) {
        this.id = id;
        this.code = code;
        this.name = name;
    }

    public Long getId() {
        return id;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof CurrencyResponse) {
            CurrencyResponse other = (CurrencyResponse) obj;
            EqualsBuilder builder = new EqualsBuilder();
            builder.append(getId(), other.getId());
            builder.append(getCode(), other.getCode());
            builder.append(getName(), other.getName());
            return builder.isEquals();
        }
        return false;
    }

    @Override
    public int hashCode() {
        HashCodeBuilder builder = new HashCodeBuilder();
        builder.append(getId());
        builder.append(getCode());
        builder.append(getName());
        return builder.toHashCode();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this).
                append("id", getId()).
                append("code", getCode()).
                append("name", getName()).
                toString();
    }
}
